package com.itheima.controller;

import com.itheima.pojo.User;
import com.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.sql.DataSource;

/**
 * @author zhouwei
 * @date 2020-01-12 11:41
 */
@RestController
public class HelloController {
    @Autowired
    private DataSource dataSource;
    @Value("${itaa.url}")
    private String itaa;
    @Value("${itbb.url}")
    private String itbb;
    @Autowired
    private UserService userService;

    @GetMapping("/hello")
    public String hello(){
        System.out.println("dataSource = " + dataSource);
        System.out.println("itaa = " + itaa);
        System.out.println("itbb = " + itbb);
        return "Hello! Spring-Boot";
    }

    @GetMapping("/user")
    public User findByid(Long id){
        User user = userService.findByid(id);
        return user;
    }
}
